/**
 * @param {string} s1
 * @param {string} s2
 * @return {number}
 */
var minimumDeleteSum = function(s1, s2) {
    let m = s1.length, n = s2.length
    const dp = new Array(m + 1).fill(0).map(() => new Array(n + 1).fill(0))

    dp[0][0] = 0
    for(let i = 1; i <= s2.length; ++i)
        dp[0][i] = dp[0][i - 1] + s2[i - 1].charCodeAt()

    for(let i = 1; i <= s1.length; ++i)
        dp[i][0] = dp[i - 1][0] + s1[i - 1].charCodeAt()

    for(let i = 1; i <= s1.length; ++i)
    {
        for(let j = 1; j <= s2.length; ++j)
        {
            let a = s1[i - 1].charCodeAt(), b = s2[j - 1].charCodeAt()
            if(a === b)
                dp[i][j] = dp[i - 1][j - 1]
            else
                dp[i][j] = Math.min(dp[i - 1][j] + a, dp[i][j - 1] + b)
        }
    }
    return dp[m][n]
};